package test.com.sms.selenium.singlepoint.util;

import org.openqa.selenium.By;

import test.com.sms.selenium.framework.SeleniumPageUtil;
import test.com.sms.selenium.util.SeleniumUtil;

public class SpAssetsListPageUtil extends SeleniumPageUtil {

	public final static By ASL_SPAN_HEADER_TITLE = By.id("ctl44_AssetReport_Header_lblHeader");
	public final static By ASL_IMG_HEADER_REPORT = By.id("ctl44_AssetReport_Header_imgPreferences");
	public final static By ASL_IMG_HEADER_EXPORT = By.id("ctl44_AssetReport_Header_imgExcelExport");
	public final static By ASL_TD_PAGE = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr/td[1]");
	public final static By ASL_SPAN_PAGE_NO = By.id("ctl44_AssetReport_PagingTop_lblPagingPageNumber");
	public final static By ASL_TD_OF = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr/td[3]");
	public final static By ASL_IMG_PAGE_FIRST = By.id("ctl44_AssetReport_PagingTop_imgFirst");
	public final static By ASL_IMG_PAGE_PREVIOUS = By.id("ctl44_AssetReport_PagingTop_imgPrevious");
	public final static By ASL_IMG_PAGE_NEXT = By.id("ctl44_AssetReport_PagingTop_imgNext");
	public final static By ASL_IMG_PAGE_LAST = By.id("ctl44_AssetReport_PagingTop_imgLast");
	public final static By ASL_TH_ASLET = By.id("ctl44_AssetReport_sort_0");
	public final static By ASL_TH_ASLET_TYPE = By.id("ctl44_AssetReport_sort_1");
	public final static By ASL_TH_MFG_NAME = By.id("ctl44_AssetReport_sort_2");
	public final static By ASL_TH_MODEL = By.id("ctl44_AssetReport_sort_3");
	public final static By ASL_TH_SERIAL_NUM = By.id("ctl44_AssetReport_sort_4");
	public final static By ASL_TH_STATUS = By.id("ctl44_AssetReport_sort_5");
	public final static By ASL_TH_DESC = By.id("ctl44_AssetReport_sort_6");
	public final static By ASL_TH_ADD_NAME = By.id("ctl44_AssetReport_sort_7");
	public final static By ASL_TH_IP_ADD = By.id("ctl44_AssetReport_sort_8");
	public final static By ASL_TH_SMS = By.id("ctl44_AssetReport_sort_9");
	
	/** filters*/
	public final static By ASL_IMG_FILTER_1 = By.id("ctl44_AssetReport_filter_0");
	public final static By ASL_IMG_FILTER_2 = By.id("ctl44_AssetReport_filter_1");
	public final static By ASL_IMG_FILTER_3 = By.id("ctl44_AssetReport_filter_2");
	public final static By ASL_IMG_FILTER_4 = By.id("ctl44_AssetReport_filter_3");
	public final static By ASL_IMG_FILTER_5 = By.id("ctl44_AssetReport_filter_4");
	public final static By ASL_IMG_FILTER_6 = By.id("ctl44_AssetReport_filter_5");
	public final static By ASL_IMG_FILTER_7 = By.id("ctl44_AssetReport_filter_6");
	public final static By ASL_IMG_FILTER_8 = By.id("ctl44_AssetReport_filter_7");
	public final static By ASL_IMG_FILTER_9 = By.id("ctl44_AssetReport_filter_8");
	public final static By ASL_IMG_FILTER_10 = By.id("ctl44_AssetReport_filter_9");
	
	// results element
	public final static By ASL_SPAN_RESULTS = By.id("ctl44_AssetReport_ReportOutput");
	
	/** elements of filter page*/
	public final static By ASL_INPUT_CONTENT = By.id("ctl44_AssetReport_txtFilterInput");
	public final static By ASL_BUTTON_ENTER = By.id("ctl44_AssetReport_btnFilterEnter");
	public final static By ASL_BUTTON_CANCEL = By.id("ctl44_AssetReport_btnFilterCancel");
	public final static By ASL_BUTTON_CLEAR = By.id("ctl44_AssetReport_btnFilterClear");
	
	
	public static void enterAssetsListPage(){
		SpHomePageUtil.enter();
		SeleniumUtil.click(SpHomePageUtil.getMainMenuAssets());
		SeleniumUtil.waitOnElements(new By[]{SpHomePageUtil.HOME_SUB_MENU_AST_LIST});
		SeleniumUtil.click(SpHomePageUtil.getAssetsList());
		SeleniumUtil.waitForFixedMilliseconds(1000);
		waitForAssetsListPageToLoad();
	}
	public static void waitForAssetsListPageToLoad(){
		//asset search page in content area
		SeleniumUtil.selectDefaultContent();
		SeleniumUtil.selectFrame(SpHomePageUtil.HOME_FRAME_CONTENT_NAME);
		SeleniumUtil.waitOnElements(new By[]{
				ASL_TH_ASLET,ASL_TH_ASLET_TYPE,ASL_TH_MFG_NAME,ASL_TH_MODEL,ASL_TH_SERIAL_NUM,ASL_TH_STATUS,
				ASL_TH_DESC,ASL_TH_ADD_NAME,ASL_TH_IP_ADD,ASL_TH_SMS
			});
		SeleniumUtil.waitForFixedMilliseconds(3000);
	}
	public static void waitForFilterPageToLoad(){
		SeleniumUtil.waitOnElements(new By[]{
				ASL_TH_ASLET,ASL_TH_ASLET_TYPE,ASL_TH_MFG_NAME,ASL_TH_MODEL,ASL_TH_SERIAL_NUM,ASL_TH_STATUS,
				ASL_TH_DESC,ASL_TH_ADD_NAME,ASL_TH_IP_ADD,ASL_TH_SMS
		});
		SeleniumUtil.waitForFixedMilliseconds(10000);
	}
}
